

import 'package:flutter/material.dart';
import 'package:sy_flutter_alipay/sy_flutter_alipay.dart';
import 'package:dio/dio.dart';
class AliPayPage extends StatefulWidget {
  @override
  _AliPayPageState createState() => _AliPayPageState();
}

class _AliPayPageState extends State<AliPayPage> {
  _doPay() async{
    //签名后的订单信息  http://agent.itying.com/alipay/index.php
    var serverapi = "http://agent.itying.com/alipay/index.php";
    var serverData =await Dio().get(serverapi);
    print(serverData.data);
    var payInfo = serverData.data;
    //alipay_sdk=alipay-sdk-php-20161101&app_id=2021001101650741&biz_content=%7B%22body%22%3A%22%5Cu6211%5Cu662f%5Cu6d4b%5Cu8bd5%5Cu6570%5Cu636e%22%2C%22subject%22%3A%22App%5Cu652f%5Cu4ed8%5Cu6d4b%5Cu8bd5111%22%2C%22out_trade_no%22%3A%2220191226213502st11%22%2C%22timeout_express%22%3A%2230m%22%2C%22total_amount%22%3A%220.01%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay¬ify_url=http%3A%2F%2Fagent.itying.com%2Falipay%2Fnotify_url.php&sign_type=RSA2×tamp=2019-12-26+21%3A35%3A02&version=1.0&sign=XZPJk2xO%2FStMwYV1dfQa%2BkjTVL6Aggw2FBkhw9%2BSTi8NieNdCIuWtUb8K5KucwNQiPDmwtiBZk0jtwilkJI1vP%2FT%2FwAGBcTnO%2Bkzu07s73yOutAMs2NHMi1lhm2Q82BwPGJRGRvbMmYzm%2BvQDelmZee73NFNksncv6iPER5zkzaguR4KxJZN8JukRQGmiMzERahtLeYzceRQi4u8iREqxGm1GlNm8rellTpMcNM9SyYUtQbgzJX2FK%2BmhSX3hFkV0D%2BMbaKd4OjNwZcG0uY%2Fi9zKRdRZZMhcrVL5KC1E1POjKgcZovH01W6VdEiNGWd%2BWrbfKMbOZUnQG8dNWbLYiw%3D%3D
    //alipay_sdk=alipay-sdk-php-20161101&app_id=2021001101650741&biz_content=%7B%22body%22%3A%22%5Cu6211%5Cu662f%5Cu6d4b%5Cu8bd5%5Cu6570%5Cu636e%22%2C%22subject%22%3A%22App%5Cu652f%5Cu4ed8%5Cu6d4b%5Cu8bd5111%22%2C%22out_trade_no%22%3A%2220191226205925st11%22%2C%22timeout_express%22%3A%2230m%22%2C%22total_amount%22%3A%220.01%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay¬ify_url=http%3A%2F%2Fagent.itying.com%2Falipay%2Fnotify_url.php&sign_type=RSA2×tamp=2019-12-26+20%3A59%3A25&version=1.0&sign=NrvbWSVxYQmouWugnKIPkkvD%2Bm%2Fi3QNBCKgFkZFPWWYohgy6To0vlAALesbNJdjFHRersicnsYphjk8Lxh1bI8HLx91pwhvv%2Fv7kMpeKcLg4DuAHjmYxA4zaxcika80FHliGBeLN9GXXt0g847upNQzasTuD4lbbFYCpnUwjIPE72C4%2BD6ej1MenGRTjD%2F6pqefJWFlvXhb4gUB34G5xKl1CRm%2BnTlJa792AVpW%2Bt1SoQgCw2oXymJafR3Vtf3uGJU%2Ftkq%2FTL1FiURcb9RbzOqPUrySQPK0%2BRVD2W9TP%2BpAj0P%2BP0NW61%2FVg3PX80DzygPLtLgdZOwlgoPfrfk6OLQ%3D%3D";
    var result = await SyFlutterAlipay.pay(
      payInfo,
      //urlScheme: '你的ios urlScheme', //前面配置的urlScheme
      //isSandbox: true //是否是沙箱环境，只对android有效
    );
    print(result);
    print("1111111");
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("支付宝支付"),
      ),
      body: Center(
        child: RaisedButton(
            onPressed: this._doPay,
            child: Text("支付")),
      ),
    );
  }
}
